const request = (funName,params)=>{
	const token = uni.getStorageSync('token')
	if(!token){
		uni.reLaunch({
			url:'/pages/login/login'
		})
	}
	return new Promise((resolve)=>{
		uniCloud.callFunction({
			name:funName,
			data:{
				params
			},
			success:res=>{
				if(res.code==200){
					resolve(res.data)
				}else{
					uni.showToast({
						title:res.message || "请求失败"
					})
					console.warn('------------uniCloud------------')
					console.warn(`${funName}请求失败`)
					console.warn(`参数：`)
					console.warn(`${params}`)
					console.warn('------------uniCloud------------')
					resolve()
				}
			},
			fail:()=>{
				resolve(false)
			}
		})
	})
}

export default request